package composite;

public class CompositeMain {
    public static void main(String[] args) {
        // 鼠标菜单
        Menu mouse = new Menu("ROOT");
        // 添加菜单项
        mouse.add(new ActionMenuItem("打开"));
        mouse.add(new ActionMenuItem("属性"));

        // 新增（新建）子菜单，并且向该子菜单添加菜单项
        Menu newChild = new Menu("新建");
        newChild.add(new ActionMenuItem("word 文档"));
        newChild.add(new ActionMenuItem("txt 文本文件"));

        // 鼠标菜单（主菜单）添加该子菜单（新建）
        mouse.add(newChild);

        mouse.print("");
    }
}
